﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace CashFlow.Entities.Models
{
	public class CashFlowListModel
	{
		public string MonthValue { get; set; }
		public string MonthLabel { get; set; }
		public string BeginningBalance { get; set; }
		public string EndingBalance { get; set; }
		public IEnumerable<CashFlowListItem> Items { get; set; }

		/// <summary>
		/// Initializes a new instance of the <see cref="T:CashFlowListModel"/> class.
		/// </summary>
		public CashFlowListModel()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="T:CashFlowListModel"/> class with a
		/// specific monthly cash flow data.
		/// </summary>
		/// <param name="cashFlow">Type: <see cref="T:MonthCashFlow"/>. The monthl cash flow data.</param>
		public CashFlowListModel(MonthCashFlow cashFlow)
		{
			MonthValue = cashFlow.MonthDate.ToString("yyMM");
			MonthLabel = cashFlow.MonthDate.ToString("MMMM yyyy");
			//TODO: vvs p2 apply region specific currency formatting
			BeginningBalance = cashFlow.BeginingBalance.ToString("C");
			EndingBalance = cashFlow.EndingBalance.ToString("C");
			Items = cashFlow.Items.Select(c => new CashFlowListItem
			{
				BillId = c.Bill.Id,
				Amount = c.Bill.Amount.ToString("C"),
				AmountNumberClass = "",
				Balance = c.Balance.ToString("C"),
				BalanceNumberClass = "",
				Date = c.Date.ToShortDateString(),
				Description = c.Bill.Details,
				Payee = c.Bill.PayeeName
			});
		}
	}

}
